﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using BizProxy.Models;
using Creative85.Framework.Utilities;

namespace BizProxy
{
    internal static class RequestHelper
    {
        public static JsonResultModel<T> PostJson<T>(string url, object data)
        {
            var ret = string.Empty;
            ret = RequestUtility.HttpPost(url, data, Timeout.Infinite);
            var json = JsonUtility.FromJson<JsonResultModel<T>>(ret);
            return json;
        }
        public static T GetDataWithPostJson<T>(string url, object data)
        {
            var json = PostJson<T>(url, data);
            if (json.code != 0) { throw new NotSupportedException(json.msg); }
            return json.data;
        }
    }
}
